package com.example.a_lambda;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class DemoTest {
    public static void main(String[] args) {
        ArrayList<Person> list = new ArrayList<>();
        list.add(new Person("小明", 18));
        list.add(new Person("小军", 48));
        list.add(new Person("小张", 28));
        Collections.sort(list, (o1, o2) ->
                o1.getAge() - o2.getAge()
        );

        System.out.println("排序后的列表list：" + list);
    }
}
